package cn.itsource.hrm.web.controller;

import cn.itsource.hrm.dto.SMSSendDto;
import cn.itsource.hrm.service.IVerifycodeService;
import cn.itsource.hrm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IVerifycodeService verifycodeService;


    @RequestMapping(value = "/imageCode/{imageCodeKey}",method = RequestMethod.GET)
    public AjaxResult imageCode(@PathVariable("imageCodeKey") String imageCodeKey){

        String base64forImage = verifycodeService.imageCode(imageCodeKey);
        return AjaxResult.me().setResultObj(base64forImage);

    }

    @RequestMapping(value = "/sendSmsCode",method = RequestMethod.POST)
    public AjaxResult sendSmsCode(@RequestBody SMSSendDto dto){

        verifycodeService.sendSmsCode(dto);
        return AjaxResult.me();
    }
}
